#include <QtGui>

#include "./include/searchItem.h"
#include "include/define.h"

SearchItem::SearchItem(QWidget *parent)
    :Item(parent)
{
    isClicked = false;

    CreateWidget();
    CreateLayout();
}

void SearchItem::CreateWidget()
{
    id = new QLabel(" ", this);
    pos = new QLabel(" ", this);
    icon = new QLabel(" ", this);
}

void SearchItem::CreateLayout()
{
    QHBoxLayout *topLayout = new QHBoxLayout;
    topLayout->addWidget(id);
    topLayout->addWidget(icon);

    QVBoxLayout *mainLayout = new QVBoxLayout;
    mainLayout->addLayout(topLayout);
    mainLayout->addWidget(pos);

    QSizePolicy policy = sizePolicy();
    policy.setHorizontalPolicy(QSizePolicy::Expanding);
    policy.setVerticalPolicy(QSizePolicy::Expanding);
    setSizePolicy(policy);

    policy = id->sizePolicy();
    policy.setHorizontalPolicy(QSizePolicy::Expanding);
    policy.setVerticalPolicy(QSizePolicy::Expanding);
    id->setSizePolicy(policy);

    policy = icon->sizePolicy();
    policy.setHorizontalPolicy(QSizePolicy::Expanding);
    policy.setVerticalPolicy(QSizePolicy::Expanding);
    icon->setSizePolicy(policy);

    policy = pos->sizePolicy();
    policy.setHorizontalPolicy(QSizePolicy::Expanding);
    policy.setVerticalPolicy(QSizePolicy::Expanding);
    pos->setSizePolicy(policy);

    setLayout(mainLayout);
}

void SearchItem::SwitchToObject()
{

}

void SearchItem::mouseDoubleClickEvent(QMouseEvent *)
{
    isClicked = true;
}
